<?php

namespace App\Providers;

use App\Services\CartPriceService;
use App\Services\ErrorMessageService;
use App\Services\FormValidationService;
use App\Services\SecurityService;
use App\Services\LogService;
use App\Services\CacheService;
use App\Services\NotificationService;
use App\Services\FileService;
use App\Services\ValidationService;
use App\Services\AfterSalesService;
use App\Services\PaymentService;
use App\Services\OrderService;
use App\Services\ProductService;
use App\Services\StockService;
use App\Services\CouponService;
use App\Services\PriceCalculationService;
use App\Observers\OrderObserver;
use App\Observers\ProductObserver;
use App\Observers\UserObserver;
use App\Models\Order;
use App\Models\Product;
use App\Models\User;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        // 注册服务类
        $this->app->singleton(CartPriceService::class);
        $this->app->singleton(ErrorMessageService::class);
        $this->app->singleton(FormValidationService::class);
        $this->app->singleton(SecurityService::class);
        $this->app->singleton(LogService::class);
        $this->app->singleton(CacheService::class);
        $this->app->singleton(NotificationService::class);
        $this->app->singleton(FileService::class);
        $this->app->singleton(ValidationService::class);
        $this->app->singleton(AfterSalesService::class);
        $this->app->singleton(PaymentService::class);
        $this->app->singleton(OrderService::class);
        $this->app->singleton(ProductService::class);
        $this->app->singleton(StockService::class);
        $this->app->singleton(CouponService::class);
        $this->app->singleton(PriceCalculationService::class);
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // 注册模型观察者
        Order::observe(OrderObserver::class);
        Product::observe(ProductObserver::class);
        User::observe(UserObserver::class);
    }
}